<%@ page language="java" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@page import="org.jasig.cas.client.authentication.AttributePrincipal"%>
<%@page import="org.jasig.cas.client.util.AssertionHolder"%>
<%
    String path = request.getContextPath();
	AttributePrincipal principal = null;

	if (request.getUserPrincipal() != null) {
		principal = (AttributePrincipal) request.getUserPrincipal();
		response.sendRedirect(path + "/index.jsp");
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户端登录cas-demo</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery.js"></script>
<script type="text/javascript">
	var loginValidate = function() {
		var msg;
		if ($.trim($('#username').val()).length == 0) {
			msg = "用户名不能为空。";
		} else if ($.trim($('#password').val()).length == 0) {
			msg = "密码不能为空。";
		}
		if (msg && msg.length > 0) {
			$('#J_ErrorMsg').fadeOut().text(msg).fadeIn();
			return false;
		}
	};

	var logincallback = function(result) {
		if (result.ret == 0) {
			//document.getElementById("callback").src = result.callBackUrl; 此方法IE会存在兼容性问题
			window.callback.location=result.callBackUrl;
			setTimeout("redirect()", 100);
		} else {
			alert(result.msg);
		}
	};

	var redirect = function() {
		location.href = "<%=path %>" + "/index.jsp";
	}
</script>
</head>
<body>

	<form id="login-form"
		action="<%=path %>/realSubmit"
		method="post" onsubmit="return loginValidate();" target="rlogin">
		<!-- <form id="login-form" action="https://demo.micmiu.com:8443/cas/login" method="post" onsubmit="return loginValidate();" target="rlogin"> -->
		<ul>
			<span style="height: 12px;" id="J_ErrorMsg"></span>

			<li><em>用户名：</em> <input name="username" id="username"
				type="text" autocomplete="off" style="width: 180px" />
			</li>
			<li><em>密 码：</em> <input name="password" type="password"
				id="password" style="width: 180px" /></li>

				<input name="" type="submit" value="登录" " /></li>
		</ul>
	</form>

	<iframe style="display: none; width: 0; height: 0" id="rlogin"
		name="rlogin"></iframe>
	<iframe style="display: none; width: 0; height: 0" id="callback"
		name="callback" src=""></iframe>
</body>
</html>